export default function zuihou(numbers, numsubs) {
  function sumArray(arr) {
    return arr.reduce((sum, current) => sum + current, 0);
  }

  let a = "";

  const sumok = sumArray(numbers);
  const sumfail = sumArray(numsubs);
  console.log(sumok, sumfail, sumok / (sumok + sumfail)); // 输出：15
  const list = [];
  numbers.forEach((i, index) => {
    const val = i / (numsubs[index] + i);
    list.push(val);
  });
  const arrsort = list.sort((a, b) => {
    return a - b;
  });
  const numpingjus =
    sumArray(arrsort.slice(3, arrsort.length - 3)) / arrsort.length;
  console.log(numpingjus);
  function roundToDecimalPlace(number, decimalPlaces) {
    const factor = Math.pow(10, decimalPlaces);
    return Math.round(number * factor) / factor;
  }
  const numzhongwei = arrsort.map((i) => {
    return roundToDecimalPlace(i * 100, 2);
  });

  function findMedian(nums) {
    // 对数组进行排序
    nums.sort(function (a, b) {
      return a - b;
    });

    // 计算数组长度
    const len = nums.length;

    // 如果数组长度是奇数，返回中间的数字
    if (len % 2 === 1) {
      return nums[(len - 1) / 2];
    }
    // 如果数组长度是偶数，返回中间两个数字的平均值
    else {
      return (nums[len / 2 - 1] + nums[len / 2]) / 2;
    }
  }

  // 示例
  const median = findMedian(numzhongwei);
  console.log(median);
}
//   zuihou(numbers,numsubs)
